package com.nuc.zyt.Service.Impl;

import com.nuc.zyt.Dao.AccountDao;
import com.nuc.zyt.Dao.UserDao;
import com.nuc.zyt.Pojo.Student;
import com.nuc.zyt.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author 耀酱
 * @Date 2023/6/5 15:52
 * @Version 1.0
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Autowired
    private AccountDao accountDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public void getMessage() {
        System.out.println("service带哦用");
        userDao.create();
    }

    @Override
    public Student getId(Integer id) {
        return userDao.getId(id);
    }

    @Override
    public void update() {
        accountDao.addAccount();
        //System.out.println(10/0);  造异常 测试事务
        accountDao.reduceAccount();
    }
}
